﻿using System;

namespace Lab2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please, enter some data:");
            ReadIntFromConsole();
            Console.ReadKey();
        }

        public static void ReadIntFromConsole()
        {
            string inputStr = Console.ReadLine();
            CheckNumber(inputStr);
        }

        private static void CheckNumber(string a)
        {
            int myNumInt;
            bool success = Int32.TryParse(a, out myNumInt);
            if (success)
            {
                ReverseNumber(myNumInt);
            }
            else
            {
                ReverseString(a);
            }
        }

        private static void ReverseNumber(int number)
        {
            int reverseString = 0;
            while (number > 0)
            {
                reverseString = reverseString * 10 + number % 10;
                number /= 10;
            }
            Console.WriteLine("You entered a number. The reverse number is: " + reverseString);
        }

        private static void ReverseString(string text)
        {
            char[] cArray = text.ToCharArray();
            string reverseNumber = String.Empty;
            for (int i = cArray.Length - 1; i > -1; i--)
            {
                reverseNumber += cArray[i];
            }
            Console.WriteLine("You entered a string. The reverse string is: " + reverseNumber);
        }
    }
}